package com.ss.android.account.b;

import android.net.Uri;
import android.os.Message;

import com.bytedance.common.utility.Logger;
import com.bytedance.common.utility.b.ThreadPlus;
import com.ss.android.account.Spipe;
import com.ss.android.account.model.ImageModel;
import com.ss.android.common.util.NetworkUtils;
import org.json.JSONObject;

final class d extends ThreadPlus {
    private final b b;
    private final String a;

    d(b arg1, String arg2) {
        this.b = arg1;
        this.a = arg2;

    }

    public final void run() {
        int v1 = 1024;
        String v0 = "";
        try {
            String v2_1 = NetworkUtils.a(Spipe.userUploadImageUrl, "photo", this.a);
            if(android.support.design.a.isTextEmpty(v2_1)) {
            }else {
                JSONObject v3 = new JSONObject(v2_1);
                if (!"success".equals(v3.optString("message"))) {
                } else {
                    v1 = 1023;
                    v0 = v3.optJSONObject("data").optString("web_uri");
                }
            }
        }
        catch(Throwable v2) {
            Logger.d("upload error", v2.toString());
        }
        Message v1_1 = this.b.e.obtainMessage(v1);
        ImageModel v2_2 = new ImageModel();
        v2_2.setLocalUri(Uri.parse("file://" + this.a));
        v2_2.setUriStr(v0);
        v1_1.obj = v2_2;
        this.b.e.sendMessage(v1_1);
    }
}

